package com.company.cloud.mall.modules.task.service;

import com.company.cloud.common.bean.LoginSimpleUserInfo;
import com.company.cloud.mall.modules.mgr.service.ShopAfterOrderPayService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Log4j2
@Component
public class ShopAfterOrderTaskService {
	
	@Autowired
	private ShopAfterOrderPayService shopAfterOrderPayService;
	
	/**
	 * 退款结果查询任务
	 * */
	@Scheduled(cron = "0 0/4 * * * ?")
//	@XxlJob("Mall_RefundResult_JobHandler")
	public String refundResultQueryTask(String param) throws Exception{
		String nowDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
//		// XxlJobLogger.log("+++++退款结果查询任务[开始],ShopAfterOrderTaskService.refundResultQueryTask,date={}",nowDate);
		log.debug("+++++退款结果查询任务[开始],ShopAfterOrderTaskService.refundResultQueryTask,date={}",nowDate);
		LoginSimpleUserInfo userInfo = this.getLoginUserInfo();
//		// XxlJobLogger.log("+++++退款结果查询任务[结束],ShopAfterOrderTaskService.refundResultQueryTask,完成");
		shopAfterOrderPayService.queryRefundResult(userInfo);
		return "SUCCESS";
	}
	
	private LoginSimpleUserInfo getLoginUserInfo() {
		LoginSimpleUserInfo userInfo = new LoginSimpleUserInfo();
		userInfo.setId(-10);
		userInfo.setUserName("SYS-Task");
		userInfo.setIp("127.0.0.1");
		return userInfo;
	}
	
	
}
